//============================================================================
// Name        : TCPSocket.h
// Author      : O.M.A.V.
// Description : De header van de TCPSocket class
//============================================================================

#ifndef TCPSOCKET_H_
#define TCPSOCKET_H_

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>

#include "../hostinfo/hostinfo.h"

using namespace std;

class TCPSocket {
public:
	// Constructors
	TCPSocket(char *interface, unsigned short int portNumber, int queueLength);
	TCPSocket(int sock);

	// Public functions prototypes
	TCPSocket *accept();
	void send(const char *msg);
	int recv(char *buffer, int bufferLength);

private:
	// Private function prototypes
	void bindSocket(char *interface, unsigned short int portNr);
	void throwError(const char msg[]) const;
	void listen(int queueLength);

	// private variables
	int sock;
};

#endif
